﻿using System;
using System.Net.Sockets;
using System.Text;

namespace TcpClientTest
{
    class Program
    {
        static void Main(string[] args)
        {
            TcpClient tcpClient = new TcpClient("127.0.0.1", 500);

            NetworkStream networkStream = tcpClient.GetStream();
            byte[] sendMessage = Encoding.UTF8.GetBytes("client request connection!");
            networkStream.Write(sendMessage, 0, sendMessage.Length);
            networkStream.Flush();

            byte[] receiveMessage = new byte[1024];
            int count = networkStream.Read(receiveMessage, 0, 1024);
            Console.WriteLine(Encoding.UTF8.GetString(receiveMessage));
            Console.ReadKey();
        }
    }
}
